//在构造函数上创建特权方法
function MyObject(){
    //1.私有变量和私有方法
    let privateVariable = 10;
    function privateFunction(){
        console.log('privateFunction');
    }
    //2.特权方法
    this.publicMethod = function(){
        return {
            privateVariable:privateVariable,
            privateFunction:privateFunction
        }
    }
}
let obj = new MyObject();
// obj.privateFunction()//TypeError: obj.privateFunction is not a function
// console.log(obj.privateVariable)//undefined
(obj.publicMethod()).privateFunction()//privateFunction
console.log((obj.publicMethod()).privateVariable)//10
